package com.gxuwz.cyhschool;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class notice extends Activity {

    private ListView mListView;

    private String [] titles = {"2020级新生绑卡情况","北校区断电情况","水费电费充值情况"};

    private String [] prices = {"14:58:02     来源：一卡通技术","14:09:02    来源：一卡通技术","14:01:02     来源：一卡通技术"};

    private int [] icons = {R.drawable.balance,R.drawable.balloon,R.drawable.bank,R.drawable.bankcard,R.drawable.biao,R.drawable.breturn};



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notice);
        ImageView imageView=findViewById(R.id.iv_return);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        mListView = (ListView) findViewById(R.id.lv);
        MyBaseAdapter mAdapter = new MyBaseAdapter();
        mListView.setAdapter(mAdapter);


        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                // 在这里执行跳转操作，例如启动一个新的Activity
                Intent intent = new Intent(notice.this, content.class);
                startActivity(intent);
            }
        });
    }
    class MyBaseAdapter extends BaseAdapter {
        @Override
        public int getCount(){
            return titles.length;
        }
        @Override
        public Object getItem(int position){
            return titles[position];
        }
        @Override
        public long getItemId(int position){
            return position;
        }
        @Override
        public View getView(int position , View convertView , ViewGroup parent){
            View view = View.inflate(notice.this,R.layout.list_item,null);
            TextView title = (TextView) view.findViewById(R.id.title);
            TextView price = (TextView) view.findViewById(R.id.price);
            ImageView iv = (ImageView) view.findViewById(R.id.iv);

            title.setText(titles[position]);
            price.setText(prices[position]);
            iv.setBackgroundResource(icons[position]);
            return view;
        }
    }
}